// models/article.go
package models

type Article struct {
	BaseModel
	Title      string `gorm:"size:200;not null" json:"title"`
	Content    string `gorm:"type:longtext;not null" json:"content"`
	Summary    string `gorm:"type:text" json:"summary"`
	CoverImage string `gorm:"size:255" json:"coverImage"`
	Status     string `gorm:"size:20;default:draft" json:"status"` // draft, published
	Views      int    `gorm:"default:0" json:"views"`
	Likes      int    `gorm:"default:0" json:"likes"`
	UserID     uint   `gorm:"not null" json:"userId"`
	CategoryID uint   `gorm:"not null" json:"categoryId"`

	// 关联
	User     User     `json:"user"`
	Category Category `json:"category"`
	Tags     []Tag    `gorm:"many2many:article_tags;" json:"tags"`
}

type Tag struct {
	BaseModel
	Name     string    `gorm:"size:50;uniqueIndex;not null" json:"name"`
	Articles []Article `gorm:"many2many:article_tags;" json:"-"`
}
